// API接口统一管理
import requests from "./request";
import mockRequest from './mockRequest';

// *三级联动的接口 oyy
export const reqCategoryList = () => requests({
    url: '/product/getBaseCategoryList',
    method: 'get'
});

// *获取banner（首页轮播图） mock
export const reqGetBannerList = () => mockRequest({
    url: '/banner',
    method: 'get'
});

// *获取floor mock
export const reqGetFloorList = () => mockRequest({
    url: '/floor',
    method: 'get'
});

// *获取搜索模块数据 oyy 收到的属性名都改一下(ok)
export const reqGetSearchInfo = (params) => requests({
    url: '/search/list',
    method: 'post',
    data: params
})

// *获取产品详情信息 xj
export const reqGoodsInfo = (skuId) => requests({
    url: `/product/skuinfo/item/${skuId}`,
    method: 'get'
})

// *将产品添加到购物车中（或者更新某一产品的个数） zh
export const reqAddOrUpdateShopCart = (skuId, skuNum) => requests({
    url: `/cart/addCartItem?skuId=${skuId}&num=${skuNum}`,
    method: 'get'
})

// *获取购物车列表数据的接口 zh
export const reqCartList = () => requests({
    url: `/cart/cartList`,
    method: 'get'
})

// *删除购物车商品 zh
export const reqDeleteCartById = (skuId) => requests({
    url: `/cart/deleteItem?skuId=${skuId}`,
    method: 'delete'
})

// *切换商品选中状态 zh
export const reqUpdateCheckedById = (skuId, isChecked) => requests({
    url: `/cart/checkItem?skuId=${skuId}&checked=${isChecked}`,
    method: 'get'
})

// *获取验证码 oyy 不自动填入（ok）
export const reqGetCode = (phone) => requests({
    url: `/user/passport/sendCode?phone=${phone}`,
    method: 'get'
})

// *注册 oyy
export const reqUserRegister = (data) => requests({
    url: '/user/passport/register',
    data,
    method: 'post'
})

// *登录 oyy
export const reqUserLogin = (data) => requests({
    url: '/user/passport/login',
    data,
    method: 'post'
})

// *第三方登录 oyy 返回给后端code，如果成功跳转 失败跳转(ok)
export const reqSsoUserLogin = (code) => requests({
    url: `/user/passport/ssologin?code=${code}`,
    method: 'get'
});

// *获取用户信息【需要带着用户的token向服务器要用户信息】 oyy
export const reqUserInfo = () => requests({
    url: '/user/passport/auth/getUserInfo',
    method: 'get'
});

// *退出登录 oyy
export const reqLogout = () => requests({
    url: '/user/passport/logout111',
    method: 'get'
});

// *获取商品清单(挂载交易界面时调用) xj
export const reqOrderInfo = () => requests({
    url: '/order/order/toTrade',
    method: 'get'
})

// *提交订单（点击提交订单调用该接口，并携带orderId跳转到支付页） xj
export const reqSubmitOrder = (data) => requests({
    url: `/order/order/submitOrder`,
    data,
    method: 'post'
})

// *获取订单支付信息（挂载支付页面时调用） xj
export const reqPayInfo = (orderId) => requests({
    url: `/order/order/aliPayOrder?orderSn=${orderId}`,
    method: 'get'
})

// 获取支付订单状态（定时器中获取订单支付的状态） xj
export const reqPayStatus = (orderId) => requests({
    url: `/payment/weixin/queryPayStatus/${orderId}`,
    method: 'get'
});

// *获取订单的数据（我的订单） xj
export const reqMyOrderList = (page, limit) => requests({
    url: `/order/order/listWithItem`,
    data: { page, limit },
    method: 'post'
});